//
//  MyOrderCell.m
//  Courses
//
//  Created by YiXuePxh on 15/4/9.
//  Copyright (c) 2015年 boyibang. All rights reserved.
//

#import "MyOrderCell.h"
#import "UIImageView+WebCache.h"
#import "NSDate+WTF.h"
@implementation MyOrderCell
{
    UILabel* _orderNo;
    UILabel* _orderTime;
    UIImageView* _imageView;
    UILabel* _courseName;
    UILabel* _orderStatus;
    UILabel* _realAmount;
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (!self) {
        return self;
    }
    self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    self.backgroundColor = nil;
    self.frame = AutoRectMake(0, 0, DEFAULT_WIDTH, 110, WTFAutoLayoutTypePic);
    _orderNo = [[UILabel alloc]initWithFrame:AutoRectMake(15, 10, 300, 15, WTFAutoLayoutTypeText)];
    _orderNo.font = [UIFont fontWithName:nil size:FONT_SIZE_TEXT_DEFAULT];
    [self.contentView addSubview:_orderNo];
    
    _orderTime = [[UILabel alloc]initWithFrame:AutoRectMake(15, 25, 200, 15, WTFAutoLayoutTypeText)];
    _orderTime.font = [UIFont fontWithName:nil size:FONT_SIZE_TEXT_DEFAULT];
    [self.contentView addSubview:_orderTime];
    
    _imageView = [[UIImageView alloc]initWithFrame:AutoRectMake(10, 45, 80, 60, WTFAutoLayoutTypeRaw)];
    _imageView.contentMode = UIViewContentModeScaleAspectFit;
    _imageView.layer.cornerRadius = 18;
    _imageView.layer.masksToBounds = YES;
    [self.contentView addSubview:_imageView];
    
    _courseName = [[UILabel alloc]initWithFrame:AutoRectMake(100, 45, 200, 20, WTFAutoLayoutTypeText)];
    _courseName.font = [UIFont fontWithName:nil size:FONT_SIZE_TEXT_DEFAULT];
    [self.contentView addSubview:_courseName];
    
    _orderStatus = [[UILabel alloc]initWithFrame:AutoRectMake(100, 65, 200, 20, WTFAutoLayoutTypeText)];
    _orderStatus.font = [UIFont fontWithName:nil size:FONT_SIZE_TEXT_DEFAULT];
    [self.contentView addSubview:_orderStatus];
    
    _realAmount = [[UILabel alloc]initWithFrame:AutoRectMake(100, 85, 200, 20, WTFAutoLayoutTypeText)];
    _realAmount.font = [UIFont fontWithName:nil size:FONT_SIZE_TEXT_DEFAULT];
    [self.contentView addSubview:_realAmount];
    
    return self;
}

-(void)setCourse:(OrderModel* )course{
    _course = course;
    [_imageView sd_setImageWithURL:[NSURL URLWithString:_course.teacherHeadPhotoUrl]];
    _orderNo.text = [NSString stringWithFormat:@"订单号：%@",_course.orderNo];
    _orderTime.text = [NSString stringWithFormat:@"订单日期：%@",_course.orderTime];
    
    _courseName.text = _course.courseName;
    long int status = (long)[_course.orderStatus integerValue];
    NSString* statusString;
    switch (status) {
        case 0:
            statusString = @"待支付";
            break;
        case 1:
            statusString = @"已关闭";
            break;
        case 2:
            statusString = @"部分已退款退课";
            break;
        case 3:
            statusString = @"已退货退课";
            break;
        case 4:
            statusString = @"金额不匹配";
            break;
        case 5:
            statusString = @"部分支付";
            break;
        case 6:
            statusString = @"已支付成功";
            break;
        case 7:
            statusString = @"已生效";
            break;
        default:
            break;
    }
    _orderStatus.text = [NSString stringWithFormat:@"订单状态：%@",statusString];
    _realAmount.text = [NSString stringWithFormat:@"须付：%@",_course.realAmount];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
